﻿#region GNU General Public License
// XEdit2D - XNA 2D Asset Editor
// Copyright (C) 2010  HurlBat Games

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
#endregion

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;

namespace HurlBat.XEdit2D
{
    public partial class MainForm : Form, IMainForm
    {
        Dictionary<string, Image> usedImages = new Dictionary<string, Image>();
        List<string> errors = new List<string>();

        public IAnimationsControl AnimationsControl { get { return animations; } }
        public IImagesControl ImagesControl { get { return images; } }
        public ICharactersControl CharactersControl { get { return characters; } }
        public List<string> Errors { get { return errors; } set { errors = value; } }
        public Dictionary<string, Image> UsedImages { get { return usedImages; } set { usedImages = value; } }

        private List<Node> nodes = new List<Node>();
        private List<Arrow> arrows = new List<Arrow>();
        private Arrow currentArrow = null;

        //public ToolStripLabel output

        public MainForm()
        {
            InitializeComponent();
        }

        //void pnlDiagram_Paint(object sender, PaintEventArgs e)
        //{
        //    foreach (Arrow a in arrows)
        //        a.Draw(e.Graphics, pnlDiagram);
        //    if (currentArrow != null)
        //        currentArrow.Draw(e.Graphics, pnlDiagram);
        //}

        //void pnlDiagram_MouseMove(object sender, MouseEventArgs e)
        //{
        //    if (currentArrow != null)
        //    {
        //        pnlDiagram.Refresh();
        //        //Point mouse = pnlDiagram.PointToClient(System.Windows.Forms.Control.MousePosition);
        //        //currentArrow.Size = new Size(Math.Abs(mouse.X - currentArrow.Left), Math.Abs(mouse.Y - currentArrow.Top));
        //        //toolStripLabel1.Text = string.Format("start: {0}, size: {1}", currentArrow.Location.ToString(), currentArrow.Size.ToString());
        //        //currentArrow.Refresh();
        //    }
        //}

        private void MainForm_Load(object sender, EventArgs e)
        {
            Globals.AppStore = new ApplicationStorage();
        }

        private void toolOptions_Click(object sender, EventArgs e)
        {
            OptionsDialog options = new OptionsDialog();
            options.ShowDialog();
        }

        public void ResetProgressBar()
        {
            //progBarImages.Value = 0;
            //progBarImages.Visible = true;
        }

        public void UpdateProgressBar(int value)
        {
            //progBarImages.Value = value;
        }

        public void HideProgressBar()
        {
            //progBarImages.Visible = false;
        }

        public void SwitchTab(TabType type)
        {
            switch (type)
            {
                case TabType.Images:
                    break;
                case TabType.Animations:
                    tabLeft.SelectedTab = tabAnimations;
                    break;
                case TabType.Characters:
                    tabLeft.SelectedTab = tabCharacters;
                    break;
                case TabType.MapEditor:
                    break;
                default:
                    break;
            }
        }

        
        //public void StartArrow(Node startNode, Point startMouse)
        //{
        //    if (currentArrow != null) return;
        //    currentArrow = new Arrow();
        //    currentArrow.SetStartNode(startNode);
        //}

        //public void EndArrow(Node endNode)
        //{
        //    if (currentArrow == null) return;
        //    currentArrow.SetEndNode(endNode);
        //    arrows.Add(currentArrow);
        //    currentArrow = null;
        //}
    }
}
